<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Distribution.Compat.Directory</span><span>
</span><span id="line-4"></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#listDirectory"><span class="hs-identifier">listDirectory</span></a></span><span>
</span><span id="line-5"></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#makeAbsolute"><span class="hs-identifier">makeAbsolute</span></a></span><span>
</span><span id="line-6"></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#doesPathExist"><span class="hs-identifier">doesPathExist</span></a></span><span>
</span><span id="line-7"></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#if MIN_VERSION_directory(1,2,7)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#"><span class="hs-identifier">System.Directory</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Dir</span></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../directory/src/System.Directory.html#doesPathExist"><span class="hs-identifier">doesPathExist</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-11"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#"><span class="hs-identifier">System.Directory</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../directory/src/System.Directory.html#doesPathExist"><span class="hs-identifier">doesPathExist</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Directory</span><span> </span><span class="hs-keyword">as</span><span> </span><span class="hs-identifier">Dir</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#if !MIN_VERSION_directory(1,2,2)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.FilePath</span><span> </span><span class="hs-keyword">as</span><span> </span><span class="hs-identifier">Path</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#if !MIN_VERSION_directory(1,2,5)
</span><span>
</span><span id="line-21"></span><span class="hs-identifier">listDirectory</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FilePath</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">FilePath</span><span class="hs-special">]</span><span>
</span><span id="line-22"></span><span class="hs-identifier">listDirectory</span><span> </span><span class="hs-identifier">path</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-23"></span><span>  </span><span class="hs-identifier">filter</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">fmap</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">Dir.getDirectoryContents</span><span> </span><span class="hs-identifier">path</span><span>
</span><span id="line-24"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">filename</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">filename</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-string">&quot;.&quot;</span><span> </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-identifier">filename</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-string">&quot;..&quot;</span><span class="hs-cpp">

#endif
</span><span class="hs-cpp">
#if !MIN_VERSION_directory(1,2,2)
</span><span>
</span><span id="line-30"></span><span class="hs-identifier">makeAbsolute</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FilePath</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">FilePath</span><span>
</span><span id="line-31"></span><span class="hs-identifier">makeAbsolute</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">Path.isAbsolute</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">p</span><span>
</span><span id="line-32"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-33"></span><span>    </span><span class="hs-identifier">cwd</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">Dir.getCurrentDirectory</span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">cwd</span><span> </span><span class="hs-operator">&lt;/&gt;</span><span> </span><span class="hs-identifier">p</span><span class="hs-cpp">

#endif
</span><span class="hs-cpp">
#if !MIN_VERSION_directory(1,2,7)
</span><span>
</span><span id="line-40"></span><span class="hs-identifier">doesPathExist</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FilePath</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-41"></span><span class="hs-identifier">doesPathExist</span><span> </span><span class="hs-identifier">path</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-42"></span><span>    </span><span class="hs-comment">-- not using Applicative, as this way we can do less IO</span><span>
</span><span id="line-43"></span><span>    </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">doesDirectoryExist</span><span> </span><span class="hs-identifier">path</span><span>
</span><span id="line-44"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">e</span><span>
</span><span id="line-45"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">True</span><span>
</span><span id="line-46"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">doesFileExist</span><span> </span><span class="hs-identifier">path</span><span class="hs-cpp">

#endif
</span><span>
</span><span id="line-50"></span></pre></body></html>